/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved.
 *
 */

import fs from 'fs';

import { ResModel } from './res-model.js';

/**
 * 不同target对应的资源集合模型
 *
 * @since 2022/2/23
 */
export class CoreResModelImpl implements ResModel {
  // 资源模型中的jsonpath,包括 app.json5,config.json,module.json5
  private readonly jsonPath: string;

  // 资源路径,一般为src/main/resources
  private readonly resourcePath: string;

  constructor(jsonPath: string, resourcePath: string) {
    this.jsonPath = jsonPath;
    this.resourcePath = resourcePath;
  }

  getJsonContent(): string {
    return fs.readFileSync(this.jsonPath, 'utf-8');
  }

  getResourcePath(): string {
    return this.resourcePath;
  }

  getJsonPath(): string {
    return this.jsonPath;
  }
}
